﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for PaymentsDB
/// </summary>
namespace CE.CarInsurance
{
    public class PaymentsDB
    {
    
        public Int64 Insert(Payments payments)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocCXCRMPaymentDetailsInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@PaymentId", payments.PaymentId);
            _sPara.Add("@QuoteRefNo", payments.QuoteRefNo);
            _sPara.Add("@CECarId", payments.CECarId);
            _sPara.Add("@ProviderCompanyId", payments.ProviderCompanyId);
            _sPara.Add("@RefCEUserId", payments.RefCEUserId);
            _sPara.Add("@AgentId", payments.AgentId);
            _sPara.Add("@AdminId", payments.AdminId);
            _sPara.Add("@PaymentType", payments.PaymentType);
            _sPara.Add("@PaymentMode", payments.PaymentMode);
            _sPara.Add("@PaymentOption", payments.PaymentOption);
            _sPara.Add("@NoofInstallments", payments.NoofInstallments);
            _sPara.Add("@PaymentBank", payments.PaymentBank);
            _sPara.Add("@CollectedAmount", payments.CollectedAmount);
            _sPara.Add("@AmountwithInterest", payments.AmountwithInterest);
            _sPara.Add("@TransactionType", payments.TransactionType);
            _sPara.Add("@ApproveType", payments.ApproveType);
            _sPara.Add("@PaymentRefNo", payments.PaymentRefNo);
            _sPara.Add("@IssuingBank", payments.IssuingBank);
            //_sPara.Add("@CardHolder", payments.CardHolder);
            //_sPara.Add("@CreditCardNo", payments.CreditCardNo);
            //_sPara.Add("@CardExpiryMonth", payments.CardExpiryMonth);
            //_sPara.Add("@CardExpiryYear", payments.CardExpiryYear);
            //_sPara.Add("@CVV", payments.CVV);
            _sPara.Add("@CardType", payments.CardType);
            _sPara.Add("@IsOnlinePayment", payments.IsOnlinePayment);
            _sPara.Add("@Status", payments.Status);
            _sPara.Add("@NoOfDays", payments.NoOfDays);
            _sPara.Add("@UserTypeId", payments.UserTypeId);
            _sPara.Add("@Info2", payments.Info2); // Agent Remarks
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetPayments(Int64 CECarId, Int16 IsOnlinePayment)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "[sprocCXCRMPaymentsDetailsSelectItemList]";

            SortedList _spara = new SortedList();
            _spara.Add("@CECarId", CECarId);
            _spara.Add("@IsOnlinePayment", IsOnlinePayment);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetPayments(Int64 CECarId)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "[sprocCXCRMPaymentsDetailsSelectItemList]";

            SortedList _spara = new SortedList();
            _spara.Add("@CECarId", CECarId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

    }
}